|
|
 |
|
|
|
|
hgt = DataMinHgt
End If
' Make the aspect ratio match the viewport
' aspect ratio, VAspect (set in Form_Resize). aspect = hgt / wid
If aspect > VAspect Then ' Too tall and thin. Make it wider. wid = hgt / VAspect
Else
' Too short and wide. Make it taller. hgt = wid * VAspect
End If
' Compute the new coordinates Wxmin = xmid - wid / 2
Wxmax = xmid + wid / 2
Wymin = ymid - hgt / 2
Wymax = ymid + hgt / 2
' See if we're off to one side. If wid > DataMaxWid Then
' We're wider than the picture. Center. xmid = (DataXmax + DataXmin) / 2
Wxmin = xmid - wid / 2
Wxmax = xmid + wid / 2
Else
' Else see if we're too far to one side. If Wxmin < DataXmin And Wxmax < DataXmax Then
' Adjust to the right. Wxmax = Wxmax + DataXmin - Wxmin
Wxmin = DataXmin
End If
If Wxmax > DataXmax And Wxmin > DataXmin Then
' Adjust to the left. Wxmin = Wxmin + DataXmax - Wxmax
Wxmax = DataXmax
End If
End If
If hgt > DataMaxHgt Then
' We're taller than the picture. Shrink. ymid = (DataYmax + DataYmin) / 2
Wymin = ymid - hgt / 2
Wymax = ymid + hgt / 2
Else
' See if we're too far to top or bottom. If Wymin < DataYmin And Wymax < DataYmax Then ' Adjust downward. Wymax = Wymax + DataYmin - Wymin
Wymin = DataYmin |
|
|
|
|
|